﻿Imports System
Imports System.CodeDom
Imports System.Runtime.Serialization
Imports System.Security.Permissions

Namespace System.Workflow.Activities.Rules
    <Serializable> _
    Public Class RuleEvaluationIncompatibleTypesException
        Inherits RuleException
        Implements ISerializable
        ' Methods
        Public Sub New()
        End Sub

        Public Sub New(ByVal message As String)
            MyBase.New(message)
        End Sub

        Protected Sub New(ByVal serializeInfo As SerializationInfo, ByVal context As StreamingContext)
            MyBase.New(serializeInfo, context)
            If (serializeInfo Is Nothing) Then
                Throw New ArgumentNullException("serializeInfo")
            End If
            Dim typeName As String = serializeInfo.GetString("left")
            If (typeName <> "null") Then
                Me.m_leftType = Type.GetType(typeName)
            End If
            Me.m_op = DirectCast(serializeInfo.GetValue("op", GetType(CodeBinaryOperatorType)), CodeBinaryOperatorType)
            typeName = serializeInfo.GetString("right")
            If (typeName <> "null") Then
                Me.m_rightType = Type.GetType(typeName)
            End If
        End Sub

        Public Sub New(ByVal message As String, ByVal ex As Exception)
            MyBase.New(message, ex)
        End Sub

        Public Sub New(ByVal message As String, ByVal left As Type, ByVal op As CodeBinaryOperatorType, ByVal right As Type)
            MyBase.New(message)
            Me.m_leftType = left
            Me.m_op = op
            Me.m_rightType = right
        End Sub

        Public Sub New(ByVal message As String, ByVal left As Type, ByVal op As CodeBinaryOperatorType, ByVal right As Type, ByVal ex As Exception)
            MyBase.New(message, ex)
            Me.m_leftType = left
            Me.m_op = op
            Me.m_rightType = right
        End Sub

        <SecurityPermission(SecurityAction.Demand, SerializationFormatter:=True)> _
        Public Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext)
            If (info Is Nothing) Then
                Throw New ArgumentNullException("info")
            End If
            MyBase.GetObjectData(info, context)
            info.AddValue("left", If((Not Me.m_leftType Is Nothing), Me.m_leftType.AssemblyQualifiedName, "null"))
            info.AddValue("op", Me.m_op)
            info.AddValue("right", If((Not Me.m_rightType Is Nothing), Me.m_rightType.AssemblyQualifiedName, "null"))
        End Sub


        ' Properties
        Public Property Left As Type
            Get
                Return Me.m_leftType
            End Get
            Set(ByVal value As Type)
                Me.m_leftType = value
            End Set
        End Property

        Public Property [Operator] As CodeBinaryOperatorType
            Get
                Return Me.m_op
            End Get
            Set(ByVal value As CodeBinaryOperatorType)
                Me.m_op = value
            End Set
        End Property

        Public Property Right As Type
            Get
                Return Me.m_rightType
            End Get
            Set(ByVal value As Type)
                Me.m_rightType = value
            End Set
        End Property


        ' Fields
        Private m_leftType As Type
        Private m_op As CodeBinaryOperatorType
        Private m_rightType As Type
    End Class
End Namespace

